package com._520it.smis.web.servlert;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com._520it.smis.dao.IStudentDao;
import com._520it.smis.dao.impl.StudentDaoImpl;

@WebServlet("/student/delete")
public class DeleteStudentServlet extends HttpServlet {
	
private static final long serialVersionUID = 1L;
	
	private IStudentDao dao;
	
	@Override
	public void init() throws ServletException {
		dao = new StudentDaoImpl();
	}
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String parameter = req.getParameter("id");
		if (parameter != null) {
			Long id = Long.valueOf(parameter);
			dao.delete(Long.valueOf(id));
		}
		resp.sendRedirect("/student/list");
		System.out.println("delete come");
	}

}
